package com.example.competionmanagebackend.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.competionmanagebackend.entity.Teams;
import com.example.competionmanagebackend.mapper.TeamsMapper;
import com.example.competionmanagebackend.service.TeamsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TeamsServiceImpl extends ServiceImpl<TeamsMapper, Teams>
        implements TeamsService {

    @Resource
    private TeamsMapper teamsMapper;

    @Override
    public Page<Teams> getTeamsPage(int currentPage, int pageSize) {
        Page<Teams> page = new Page<>(currentPage, pageSize);
        return this.page(page);
    }

    @Override
    public void insertTeam(Teams team) {
        teamsMapper.insertTeam(team);
    }

    @Override
    public void updateTeam(Teams team) {
        teamsMapper.updateTeam(team);
    }

    @Override
    public void deleteTeam(Integer id) {
        teamsMapper.deleteTeamById(id);
    }

    @Override
    public List<Teams> getTeamsByUserId(Integer userId) {
        return teamsMapper.selectTeamsByUserId(userId);
    }
}